class ProductOfNumbers(object):

    def __init__(self):
        self.p = []
        self.z_index = -1
        self.c = 0

    def add(self, num):
        """
        :type num: int
        :rtype: None
        """
        if num == 0:
            self.p.append(0)
            self.z_index = self.c
        else:
            if not self.p:
                self.p.append(num)
            else:
                if self.p[-1] == 0:
                    self.p.append(num)
                else:
                    self.p.append(self.p[-1] * num)
        self.c += 1

    def getProduct(self, k):
        """
        :type k: int
        :rtype: int
        """
        if self.c - k <= self.z_index:
            return 0
        else:
            if self.c - k - 1 == self.z_index:
                return self.p[-1]
            else:
                return self.p[-1] // self.p[self.c - k - 1]